import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import eslintPlugin from '@rollup/plugin-eslint';
// import styleImport from 'vite-plugin-style-import';
import path from 'path';

function _resolve(dir: string) {
    return path.resolve(__dirname, dir);
}

export default ({ command, mode }) => {
    // https://vitejs.dev/config/
    return defineConfig({
        css: {
            preprocessorOptions: {
                less: {
                    javascriptEnabled: true,
                },
            },
        },
        build: {
            manifest: true,
            // assetsInlineLimit: 200*1024,
        },
        server: {
            host: '0.0.0.0',
            port: 5173,
            open: false,
        },
        resolve: {
            alias: {
                '@': _resolve('src'),
            },
        },
        plugins: [{ ...eslintPlugin({ include: 'src/**/*.+(js|jsx|ts|tsx|vue)' }), enforce: 'pre' }, vue()],
    });
};
